
"""测试框架功能"""

import wx
import wx.lib.buttons as buttons


class CustomFrame(wx.Frame):
    """一个自定义框架"""
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Custom Frame", (500, 400))
        self.panel = wx.Panel(self, -1)
        self.simpleFrame()

    def simpleFrame(self):
        button = buttons.GenButton(self.panel, -1, "Close me", (10, 10), wx.DefaultSize)
        self.Bind(wx.EVT_BUTTON, self.onCloseMe, button)
        self.Bind(wx.EVT_CLOSE, self.onCloseWindow)

    def onCloseMe(self, e):
        """关闭按钮被点击"""
        print("onCloseMe")
        print(e.GetId())
        self.Close(True)


    def onCloseWindow(self, e):
        """左上角关闭或者调用frame.Close方法均会触发此方法, 因此可以在此方法中做保存数据等操作"""
        print("onCloseWindow")
        self.Destroy()
        pass


def customFrameDemo():
    app = wx.App()
    frame = CustomFrame()
    frame.Show(True)
    app.MainLoop()

if __name__ == "__main__":
    customFrameDemo()





